﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace Sino.CapacityCloud.Tests.Fixtures
{

    public class DatabaseFixture
        : IDisposable
    {

        public DatabaseFixture()
        {
            if (File.Exists("CapacityCloudWeb.db"))
            {
                File.Delete("CapacityCloudWeb.db");
                File.Copy("./Resources/CapacityCloudWebSeed", "CapacityCloudWeb.db", true);
            }
        }

        public void InitializeDatabase()
        {
            if (File.Exists("CapacityCloudWeb.db"))
            {
                File.Delete("CapacityCloudWeb.db");
                File.Copy("./Resources/CapacityCloudWebSeed", "CapacityCloudWeb.db", true);
            }
        }

        #region IDisposable
        // Flag: Has Dispose already been called?
        private bool disposed = false;

        // Public implementation of Dispose pattern callable by consumers.
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        // Protected implementation of Dispose pattern.
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
                return;

            if (disposing)
            {
                // Free any other managed objects here.
                //
            }

            // Free any unmanaged objects here.
            //
            disposed = true;
        }
        #endregion

    }

}